<!DOCTYPE html>
<html lang=zh>
<head>
    <meta charset="utf-8">
    
    <title>php开发环境搭建 | Hexo</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="在Windows平台上搭建~(^▽^) 其实在下载的文件中怎么配置上面都有说明，只是全是鸡肠看起来蛋疼 文章底部有一些补充的小知识和相关知识点的解释（￣︶￣）↗">
<meta property="og:type" content="article">
<meta property="og:title" content="php开发环境搭建">
<meta property="og:url" content="http://dsjerry.gitee.io/mousejerry/2020/07/24/php%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="在Windows平台上搭建~(^▽^) 其实在下载的文件中怎么配置上面都有说明，只是全是鸡肠看起来蛋疼 文章底部有一些补充的小知识和相关知识点的解释（￣︶￣）↗">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://dsjerry.gitee.io/images/phpinfo.png">
<meta property="article:published_time" content="2020-07-24T07:28:40.000Z">
<meta property="article:modified_time" content="2020-07-24T14:20:00.418Z">
<meta property="article:author" content="smalljerry">
<meta property="article:tag" content="php">
<meta property="article:tag" content="apache">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://dsjerry.gitee.io/images/phpinfo.png">
    

    
        <link rel="alternate" href="/" title="Hexo" type="application/atom+xml" />
    

    
        <link rel="icon" href="/mousejerry/css/images/ghaseminya.png" />
    

    
<link rel="stylesheet" href="/mousejerry/libs/font-awesome/css/font-awesome.min.css">

    
<link rel="stylesheet" href="/mousejerry/libs/open-sans/styles.css">

    
<link rel="stylesheet" href="/mousejerry/libs/source-code-pro/styles.css">


    
<link rel="stylesheet" href="/mousejerry/css/style.css">


    
<script src="/mousejerry/libs/jquery/2.1.3/jquery.min.js"></script>

    
    
        
<link rel="stylesheet" href="/mousejerry/libs/lightgallery/css/lightgallery.min.css">

    
    
        
<link rel="stylesheet" href="/mousejerry/libs/justified-gallery/justifiedGallery.min.css">

    
    
    
    


<meta name="generator" content="Hexo 5.0.0"></head>

<body>
    <div id="container">
        <header id="header">
    <div id="header-main" class="header-inner">
        <div class="outer">
            <a href="/mousejerry/" id="logo">
                <i class="logo"></i>
                <span class="site-title">Hexo</span>
            </a>
            <nav id="main-nav">
                
                    <a class="main-nav-link" href="/mousejerry/.">首页</a>
                
                    <a class="main-nav-link" href="/mousejerry/archives">归档</a>
                
                    <a class="main-nav-link" href="/mousejerry/categories">分类</a>
                
                    <a class="main-nav-link" href="/mousejerry/tags">标签</a>
                
                    <a class="main-nav-link" href="/mousejerry/about">关于</a>
                
            </nav>
            
                
                <nav id="sub-nav">
                    <div class="profile" id="profile-nav">
                        <a id="profile-anchor" href="javascript:;">
                            <img class="avatar" src="https://avatars2.githubusercontent.com/u/53891546?s=460&amp;u=6f987551976f2fcd6f2f49ab5b714fb72671f902&amp;v=4" />
                            <i class="fa fa-caret-down"></i>
                        </a>
                    </div>
                </nav>
            
            <div id="search-form-wrap">

    <form class="search-form">
        <input type="text" class="ins-search-input search-form-input" placeholder="搜索" />
        <button type="submit" class="search-form-submit"></button>
    </form>
    <div class="ins-search">
    <div class="ins-search-mask"></div>
    <div class="ins-search-container">
        <div class="ins-input-wrapper">
            <input type="text" class="ins-search-input" placeholder="想要查找什么..." />
            <span class="ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: '文章',
            PAGES: '页面',
            CATEGORIES: '分类',
            TAGS: '标签',
            UNTITLED: '(未命名)',
        },
        ROOT_URL: '/mousejerry/',
        CONTENT_URL: '/mousejerry/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>

<script src="/mousejerry/js/insight.js"></script>


</div>
        </div>
    </div>
    <div id="main-nav-mobile" class="header-sub header-inner">
        <table class="menu outer">
            <tr>
                
                    <td><a class="main-nav-link" href="/mousejerry/.">首页</a></td>
                
                    <td><a class="main-nav-link" href="/mousejerry/archives">归档</a></td>
                
                    <td><a class="main-nav-link" href="/mousejerry/categories">分类</a></td>
                
                    <td><a class="main-nav-link" href="/mousejerry/tags">标签</a></td>
                
                    <td><a class="main-nav-link" href="/mousejerry/about">关于</a></td>
                
                <td>
                    
    <div class="search-form">
        <input type="text" class="ins-search-input search-form-input" placeholder="搜索" />
    </div>

                </td>
            </tr>
        </table>
    </div>
</header>

        <div class="outer">
            
                

<aside id="profile">
    <div class="inner profile-inner">
        <div class="base-info profile-block">
            <img id="avatar" src="https://avatars2.githubusercontent.com/u/53891546?s=460&amp;u=6f987551976f2fcd6f2f49ab5b714fb72671f902&amp;v=4" />
            <h2 id="name">SmallJerry</h2>
            <h3 id="title">————</h3>
            <span id="location"><i class="fa fa-map-marker"></i>Mar</span>
            <a id="follow" target="_blank" href="https://github.com/dsjerry">关注我</a>
        </div>
        <div class="article-info profile-block">
            <div class="article-info-block">
                18
                <span>文章</span>
            </div>
            <div class="article-info-block">
                18
                <span>标签</span>
            </div>
        </div>
        
        <div class="profile-block social-links">
            <table>
                <tr>
                    
                    
                    <td>
                        <a href="https://github.com/dsjerry" target="_blank" title="github" class=tooltip>
                            <i class="fa fa-github"></i>
                        </a>
                    </td>
                    
                    <td>
                        <a href="/mousejerry/" target="_blank" title="rss" class=tooltip>
                            <i class="fa fa-rss"></i>
                        </a>
                    </td>
                    
                </tr>
            </table>
        </div>
        
    </div>
</aside>

            
            <section id="main"><article id="post-php开发环境搭建" class="article article-type-post" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
            <header class="article-header">
                
    
        <h1 class="article-title" itemprop="name">
            php开发环境搭建
        </h1>
    

                
                    <div class="article-meta">
                        
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/mousejerry/2020/07/24/php%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/">
            <time datetime="2020-07-24T07:28:40.000Z" itemprop="datePublished">2020-07-24</time>
        </a>
    </div>


                        
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/mousejerry/categories/%E6%8A%80%E5%B7%A7%E5%AD%A6%E4%B9%A0/">技巧学习</a>
    </div>

                        
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link-link" href="/mousejerry/tags/apache/" rel="tag">apache</a>, <a class="tag-link-link" href="/mousejerry/tags/php/" rel="tag">php</a>
    </div>

                    </div>
                
            </header>
        
        
        <div class="article-entry" itemprop="articleBody">
        
            
            <p>在Windows平台上搭建<del>~</del>(<em>^▽^</em>)</p>
<p>其实在下载的文件中怎么配置上面都有说明，只是全是鸡肠看起来蛋疼</p>
<p>文章底部有一些补充的小知识和相关知识点的解释（￣︶￣）↗　<a id="more"></a></p>
<h1 id="安装-Apache"><a href="#安装-Apache" class="headerlink" title="安装 Apache"></a>安装 Apache</h1><p><a target="_blank" rel="noopener" href="https://www.apachehaus.com/cgi-bin/download.plx">Apache下载地址</a></p>
<h2 id="配置Apache"><a href="#配置Apache" class="headerlink" title="配置Apache"></a>配置Apache</h2><p>解压下载的压缩包，打开Apache的配置文件<code>conf/httpd.conf</code></p>
<ul>
<li>找到配置项<code>Define SRVROOT</code>，将里面的路径更改为自己下载的 apache 的根目录</li>
</ul>
<blockquote>
<p>路径要使用 <code>/</code> 而不是 <code>\</code></p>
</blockquote>
<ul>
<li>找到 <code>ServerName</code>，去掉前面的<code>#</code>，这里配置自己的域名，如果没有域名，就写个IP地址上去。<ul>
<li>例如：<code>ServerName 127.0.0.1:80</code>，也可以写成 localhost:80</li>
</ul>
</li>
</ul>
<h2 id="安装-Apache-1"><a href="#安装-Apache-1" class="headerlink" title="安装 Apache"></a>安装 Apache</h2><p>以<strong>管理员</strong>的身份打开命令提示符，切换到 Apache目录下的 <code>bin</code> 目录，执行命令：</p>
<p>安装：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">httpd.exe -k install</span><br></pre></td></tr></table></figure>

<ul>
<li>提示：这里安装之前Apache文件夹的名字叫什么，安装后Apache服务的名字就叫什么</li>
</ul>
<p>卸载：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">httpd.exe -k uninstall</span><br></pre></td></tr></table></figure>

<h2 id="启动Apache服务"><a href="#启动Apache服务" class="headerlink" title="启动Apache服务"></a>启动Apache服务</h2><p>有三种启动方式，通过命令行、通过Apache软件和通过系统服务</p>
<h3 id="通过命令行启动-Apache"><a href="#通过命令行启动-Apache" class="headerlink" title="通过命令行启动 Apache"></a>通过命令行启动 Apache</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"># 启动服务</span><br><span class="line">net start Apache</span><br><span class="line"># 停止服务</span><br><span class="line">net stop Apache</span><br></pre></td></tr></table></figure>

<h3 id="通过软件启动-Apache"><a href="#通过软件启动-Apache" class="headerlink" title="通过软件启动 Apache"></a>通过软件启动 Apache</h3><p>打开apache目录下的bin目录，双击 <code>ApacheMonitor.exe</code> 启动</p>
<h3 id="通过系统服务启动Apache"><a href="#通过系统服务启动Apache" class="headerlink" title="通过系统服务启动Apache"></a>通过系统服务启动Apache</h3><p>任务管理 &gt; 服务 &gt; 打开服务 &gt; 启动apache</p>
<h2 id="访问测试"><a href="#访问测试" class="headerlink" title="访问测试"></a>访问测试</h2><p>浏览器输入：<code>localhost</code>，如果看到 <em>It works！</em> 那就成功了。Apache默认打开的是 <code>htdoc</code>目录下的 index.html</p>
<h1 id="安装PHP"><a href="#安装PHP" class="headerlink" title="安装PHP"></a>安装PHP</h1><p><a target="_blank" rel="noopener" href="https://windows.php.net/download#php-7.4">PHP 7.4 下载地址</a>，找到 <code>Thread Safe</code> 版本，下载 zip 压缩包</p>
<h2 id="创建配置文件"><a href="#创建配置文件" class="headerlink" title="创建配置文件"></a>创建配置文件</h2><p>解压之后，找到 <code>php.ini-development</code> 文件，复制粘贴一份，然后改名为 <code>php.ini</code></p>
<h2 id="在Apache中引入PHP模块"><a href="#在Apache中引入PHP模块" class="headerlink" title="在Apache中引入PHP模块"></a>在Apache中引入PHP模块</h2><ul>
<li><p>打开Apache的配置文件 httpd.conf，引入 PHP 为 Apache 提供的DLL 模块</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">LoadModule php7_module &quot;php在电脑中的路径&#x2F;php7apache2_4.dll&quot;</span><br><span class="line">&lt;FilesMatch &quot;\.php$&gt;</span><br><span class="line">  setHandler application&#x2F;x-httpd-php</span><br><span class="line">&lt;&#x2F;FilesMatch&gt;</span><br><span class="line">PHPIniDir &quot;php在电脑中的路径&#x2F;php-7.4.7&quot;</span><br><span class="line">LoadFile &quot;php在电脑中的路径&#x2F;libssh2.dll&quot;</span><br></pre></td></tr></table></figure>
</li>
<li><p>配置 Apache 的索引页</p>
<ul>
<li><p>访问 localhost 的时候，实际上是在访问 localhost/index.html。在配置文件中搜索 <code>DirectoryIndex</code></p>
</li>
<li><p>起初的模样</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;IfModule dir_module&gt;</span><br><span class="line">    DirectoryIndex index.html</span><br><span class="line">&lt;&#x2F;IfModule&gt;</span><br></pre></td></tr></table></figure>
</li>
<li><p>加上另外的 index.php </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;IfModule dir_module&gt;</span><br><span class="line">    DirectoryIndex index.php index.html</span><br><span class="line">&lt;&#x2F;IfModule&gt;</span><br></pre></td></tr></table></figure>

</li>
</ul>
</li>
</ul>
<h2 id="访问测试-1"><a href="#访问测试-1" class="headerlink" title="访问测试"></a>访问测试</h2><p>修改了 Apache 配置文件后，要重新启动一下。</p>
<p>在 Apache 的 htdoc 目录下创建一个 test.php，编辑内容：</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?php</span></span><br><span class="line">    phpinfo();</span><br><span class="line"><span class="meta">?&gt;</span></span><br></pre></td></tr></table></figure>

<p>通过访问 <code>localhost/test.php</code>测试是都安装成功 </p>
<p><img src="/images/phpinfo.png" alt="img"></p>
<h2 id="打开常用扩展"><a href="#打开常用扩展" class="headerlink" title="打开常用扩展"></a>打开常用扩展</h2><p>打开 <code>php.ini</code>，搜索 <code>extension_dir</code>，增加一行 <code>extension_dir = &quot;php安装的目录/ext&quot;</code></p>
<p>一般会启用的功能：</p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">extension</span>=curl</span><br><span class="line"><span class="attr">extension</span>=gd2</span><br><span class="line"><span class="attr">extension</span>=mbstring</span><br><span class="line"><span class="attr">extension</span>=mysqli</span><br><span class="line"><span class="attr">extension</span>=openssl</span><br><span class="line"><span class="attr">extension</span>=pdo_mysql</span><br></pre></td></tr></table></figure>

<h1 id="web服务器配置"><a href="#web服务器配置" class="headerlink" title="web服务器配置"></a>web服务器配置</h1><p>在每次修改配置文件之后都要重启 Apache 才会生效。如果想恢复默认，在<code>conf/original</code>目录中获取</p>
<h2 id="配置虚拟主机"><a href="#配置虚拟主机" class="headerlink" title="配置虚拟主机"></a>配置虚拟主机</h2><p>其实在<strong>真正使用</strong>的时候，在购买域名平台上的控制台中就可以增加和修改 dns 的映射关系。</p>
<p>在<strong>学习过程</strong>中使用Windows系统配置，可以更改系统的 <code>hosts</code> 文件，这个文件用于配置域名和IP地址之间的解析关系</p>
<h3 id="配置域名"><a href="#配置域名" class="headerlink" title="配置域名"></a>配置域名</h3><p>用<strong>管理员</strong>打开 <code>C:/Windows/System32/drivers/etc</code> 目录下的 <code>hosts</code> 文件，配置域名和IP地址的映射关系</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">127.0.0.1 php.test</span><br><span class="line">127.0.0.1 www.php.test</span><br></pre></td></tr></table></figure>

<h3 id="启用辅配置文件"><a href="#启用辅配置文件" class="headerlink" title="启用辅配置文件"></a>启用辅配置文件</h3><p>辅配置文件是 Apache 配置文件 httpd.conf 的扩展文件，默认是不启动的，去掉 <code>#</code> 将它启动</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Include conf&#x2F;extra&#x2F;httpd-vhost.conf</span><br></pre></td></tr></table></figure>

<h3 id="配置虚拟主机-1"><a href="#配置虚拟主机-1" class="headerlink" title="配置虚拟主机"></a>配置虚拟主机</h3><p>打开 <code>httpd-vhost.conf</code>文件</p>
<p>将下面这一块注释掉，作为参考</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">#&lt;VirtualHost *:80&gt;</span><br><span class="line">#    ServerAdmin webmaster@dummy-host.example.com</span><br><span class="line">#    DocumentRoot &quot;$&#123;SRVROOT&#125;&#x2F;docs&#x2F;dummy-host.example.com&quot;</span><br><span class="line">#    ServerName dummy-host.example.com</span><br><span class="line">#    ServerAlias www.dummy-host.example.com</span><br><span class="line">#    ErrorLog &quot;logs&#x2F;dummy-host.example.com-error.log&quot;</span><br><span class="line">#    CustomLog &quot;logs&#x2F;dummy-host.example.com-access.log&quot; common</span><br><span class="line">#&lt;&#x2F;VirtualHost&gt;</span><br></pre></td></tr></table></figure>

<p>新增虚拟主机</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"># 第一个虚拟主机</span><br><span class="line">&lt;VirtualHost *:80&gt;</span><br><span class="line">    DocumentRoot &quot;D:&#x2F;web&#x2F;apache&#x2F;htdocs&quot;</span><br><span class="line">    ServerName localhost</span><br><span class="line">&lt;&#x2F;VirtualHost&gt;</span><br><span class="line"># 第二个虚拟主机</span><br><span class="line">&lt;VirtualHost *:80&gt;</span><br><span class="line">    DocumentRoot &quot;D:&#x2F;web&#x2F;www&#x2F;thinkphp&#x2F;public&quot;</span><br><span class="line">    ServerName thinkphp.test</span><br><span class="line">    ServerAlias www.thinkphp.test</span><br><span class="line">&lt;&#x2F;VirtualHost&gt;</span><br></pre></td></tr></table></figure>

<ul>
<li>ServerAlias 取别名，不管访问哪个，都是指向同一网站</li>
</ul>
<blockquote>
<p>这时已经是可以访问配置好的页面了，访问 localhost 或者 thinkphp.test 测试配置</p>
<p>下面的是一些自定义的功能</p>
</blockquote>
<p>[]<del>(￣▽￣)</del>* ，✿✿ヽ(°▽°)ノ✿，ヾ(◍°∇°◍)ﾉﾞ，(<em>^▽^</em>)，(^o^)/<del>，Thanks♪(･ω･)ﾉ，٩(๑&gt;◡&lt;๑)۶，O(∩_∩)O哈哈</del></p>
<h2 id="访问权限控制"><a href="#访问权限控制" class="headerlink" title="访问权限控制"></a>访问权限控制</h2><p>控制服务器中哪些文件允许被外部访问，在 httpd.conf 中，默认站点目录 <code>htdocs</code> 已经配置为允许外部访问，其他目录要手动配置。以 <code>www.admin.test</code> 为例</p>
<p>在 <code>httpd-vhost.conf</code> 文件中：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">&lt;VirtualHost *:80&gt;</span><br><span class="line">    DocumentRoot &quot;D:&#x2F;web&#x2F;www.admin.test&quot;</span><br><span class="line">    ServerName admin.test&#96;</span><br><span class="line">&lt;&#x2F;VirtualHost&gt;</span><br><span class="line">&lt;Directory &quot;D:&#x2F;web&#x2F;www.admin.test&quot;&gt;</span><br><span class="line">    Require local</span><br><span class="line">    #Require all granted（充许局域网内其他电脑访问）</span><br><span class="line">    #Require all denied（不充许局域网内其他电脑访问）</span><br><span class="line">&lt;&#x2F;Directory&gt;</span><br></pre></td></tr></table></figure>

<ul>
<li>Require local：只允许本地访问</li>
<li>Require all granted：允许所有访问</li>
<li>Require all denied：拒绝所有访问</li>
</ul>
<h2 id="分布式配置文件"><a href="#分布式配置文件" class="headerlink" title="分布式配置文件"></a>分布式配置文件</h2><p>为目录单独进行配置的文件，可以实现在不中期服务器的前提下更改某个目录的配置，编辑 httpd-vhost.conf 文件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&lt;Directory &quot;D:&#x2F;web&#x2F;www.admin.test&quot;&gt;</span><br><span class="line">    Require local</span><br><span class="line">    AllowOverride All</span><br><span class="line">&lt;&#x2F;Directory&gt;</span><br></pre></td></tr></table></figure>

<ul>
<li>添加 <code>AllowOverride All</code> 后， Apache 回到站点下各个目录中读取名称为 “ .htaccess ” 的分布式配置文件，该文件中的配置将会覆盖原有的配置</li>
<li>这可能会影响服务器运行效率，如果想关掉，改为 <code>AllowOverride None</code></li>
</ul>
<h2 id="目录浏览功能"><a href="#目录浏览功能" class="headerlink" title="目录浏览功能"></a>目录浏览功能</h2><p>在目录“D:/web/w ww.admin.test”中创建文件 <code>.htaccess</code>，编写配置：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">Options Indexes</span><br><span class="line"># 不想使用的话</span><br><span class="line">Options -Indexes</span><br></pre></td></tr></table></figure>

<h2 id="自定义错误页面"><a href="#自定义错误页面" class="headerlink" title="自定义错误页面"></a>自定义错误页面</h2><p>在遇到错误的时候，Apache会使用 error 目录中的模板显示一个页面，通过 <code>ErrorDocument</code> 指令对不同的状态码进行配置</p>
<p>在 <Directory> 或 <code>.htaccess</code> 中，加入：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">ErrorDocument 403&#x2F;403.html</span><br><span class="line">ErrorDocument 404&#x2F;404.html</span><br><span class="line">ErrorDocument 500&#x2F;500.html</span><br></pre></td></tr></table></figure>



<p>✿✿ヽ(°▽°)ノ✿  如果深入配置的话，后面还可以配置 mysql 和 thinkPHP</p>
<h1 id="了解一下"><a href="#了解一下" class="headerlink" title="了解一下"></a>了解一下</h1><p>了解周边小知识，提高学习兴趣<del>~</del>奥利给！！！</p>
<h2 id="关于Apache"><a href="#关于Apache" class="headerlink" title="关于Apache"></a>关于Apache</h2><p>因为 Apache HTTP Server Project 它本身不提供发行的软件下载，提供下载的比如有：<a target="_blank" rel="noopener" href="http://www.apachehaus.com/cgi-bin/download.plx">ApacheHaus</a>，<a target="_blank" rel="noopener" href="http://www.apachelounge.com/download/">Apache Lounge</a>等等。这里使用的服务器软件简称是 <code>httpd</code>，是其中的一项产品，在浏览器搜索的时候搜索<code>apache httpd</code>就可以找到下载的地方了。Apache 旗下还有别的产品，比如和 Java 比较般配的 <code>Tomcat</code>，也是 Apache 旗下的。</p>
<h3 id="配置项"><a href="#配置项" class="headerlink" title="配置项"></a>配置项</h3><ul>
<li>在上面配置Apache引入PHP文件的时候，LoadModule 是加载模块的指令，加载了 php7_module 模块，下面的代码时对PHP文件的解析，利用正则表达式匹配 “ .php “ 文件，然后通过 setHandler 提交给PHP处理。PHPIniDir 用于指定 php.ini 文件保存的目录</li>
<li>在上面的设置默认入口文件的时候，首先检测是否存在 inidex.php，然后再检测 index.html</li>
</ul>
<h3 id="配置虚拟主机相关知识"><a href="#配置虚拟主机相关知识" class="headerlink" title="配置虚拟主机相关知识"></a>配置虚拟主机相关知识</h3><p>虚拟主机是 Apache 提供的<strong>一个功能</strong>，通过虚拟主机可以<strong>在一台服务器上部署多个网站</strong>，而不同的域名可以解析到同一个IP地址上。</p>
<p>因此，当用户通过不同的域名访问同一台服务器时，虚拟主机功能就可以让用户访问到不同的网站。</p>
<h3 id="会遇到的问题"><a href="#会遇到的问题" class="headerlink" title="会遇到的问题"></a>会遇到的问题</h3><h4 id="端口占用"><a href="#端口占用" class="headerlink" title="端口占用"></a>端口占用</h4><p>Apache 默认监听 80 端口，如果端口被占用，Apache将无法启动。</p>
<ul>
<li>在Windows中可以在命令提示符中使用<code>net -ano</code> 查看当前的端口情况 </li>
<li>使用 <code>tasklist | findstr &quot;PID&quot;</code>可以查看当前占用端口的是什么应用程序</li>
</ul>
<h4 id="安装多个Apache"><a href="#安装多个Apache" class="headerlink" title="安装多个Apache"></a>安装多个Apache</h4><p>Apache可以多个服务同时进行工作，前提是要服务名称和端口号不冲突。在Apache配置文件中，找到<code>Listen</code>，就可以修改监听的端口</p>
<p>安装多个Apache：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">httpd.exe -k install -n apache2</span><br></pre></td></tr></table></figure>

<p>卸载</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">httpd.exe -k uninstall -n apache2</span><br></pre></td></tr></table></figure>



<h2 id="关于PHP"><a href="#关于PHP" class="headerlink" title="关于PHP"></a>关于PHP</h2><h3 id="版本"><a href="#版本" class="headerlink" title="版本"></a>版本</h3><p>PHP除了版本的选择，还有一个选择就是 <strong>Thread Safe</strong>（线程安全）和 <strong>No Thread Safe</strong>（非线程安全）</p>
<p>PHP和Apache搭配的时候，选择Thread Safe</p>
<h3 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h3><p>php.ini-development：开发环境配置模板</p>
<p>php.ini-production：生产模式，适合上线的时候使用</p>

        
        </div>
        <footer class="article-footer">
            <div class="share-container">



    <div class="a2a_kit a2a_default_style">
    <a class="a2a_dd" target="_blank" rel="noopener" href="https://www.addtoany.com/share">分享到</a>
    <span class="a2a_divider"></span>
    <a class="a2a_button_wechat" title="微信"></a>
    <a class="a2a_button_sina_weibo" title="微博"></a>
    <a class="a2a_button_email" title="邮件"></a>
    <a class="a2a_button_qzone" title="QQ空间"></a>
    <!--    <a class="a2a_button_pinterest"></a>-->
<!--    <a class="a2a_button_tumblr"></a>-->
</div>
<script type="text/javascript" src="//static.addtoany.com/menu/page.js"></script>
<style>
    .a2a_menu {
        border-radius: 4px;
    }
    .a2a_menu a {
        margin: 2px 0;
        font-size: 14px;
        line-height: 16px;
        border-radius: 4px;
        color: inherit !important;
        font-family: 'Microsoft Yahei';
    }
    #a2apage_dropdown {
        margin: 10px 0;
    }
    .a2a_mini_services {
        padding: 10px;
    }
    a.a2a_i,
    i.a2a_i {
        width: 122px;
        line-height: 16px;
    }
    a.a2a_i .a2a_svg,
    a.a2a_more .a2a_svg {
        width: 16px;
        height: 16px;
        line-height: 16px;
        vertical-align: top;
        background-size: 16px;
    }
    a.a2a_i {
        border: none !important;
    }
    a.a2a_menu_show_more_less {
        margin: 0;
        padding: 10px 0;
        line-height: 16px;
    }
    .a2a_mini_services:after{content:".";display:block;height:0;clear:both;visibility:hidden}
    .a2a_mini_services{*+height:1%;}
</style>


</div>

            
    
        <a href="http://dsjerry.gitee.io/mousejerry/2020/07/24/php%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/#comments" class="article-comment-link disqus-comment-count" data-disqus-url="http://dsjerry.gitee.io/mousejerry/2020/07/24/php%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/">评论</a>
    

        </footer>
    </div>
    
        
<nav id="article-nav">
    
        <a href="/mousejerry/2020/07/28/php%E6%95%B0%E7%BB%84%E7%9A%84%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0/" id="article-nav-newer" class="article-nav-link-wrap">
            <strong class="article-nav-caption">上一篇</strong>
            <div class="article-nav-title">
                
                    php数组的常用函数
                
            </div>
        </a>
    
    
        <a href="/mousejerry/2020/07/23/vscode%E9%85%8D%E7%BD%AEphpcs/" id="article-nav-older" class="article-nav-link-wrap">
            <strong class="article-nav-caption">下一篇</strong>
            <div class="article-nav-title">vscode配置phpcs</div>
        </a>
    
</nav>


    
</article>


    
    <section id="comments">
    
        
    <div id="disqus_thread">
        <noscript>Please enable JavaScript to view the <a target="_blank" rel="noopener" href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    </div>

    
    </section>

</section>
            
                <aside id="sidebar">
   
        
    <div class="widget-wrap">
        <h3 class="widget-title">标签云</h3>
        <div class="widget tagcloud">
            <a href="/mousejerry/tags/PHP/" style="font-size: 13.33px;">PHP</a> <a href="/mousejerry/tags/apache/" style="font-size: 10px;">apache</a> <a href="/mousejerry/tags/express/" style="font-size: 10px;">express</a> <a href="/mousejerry/tags/js/" style="font-size: 13.33px;">js</a> <a href="/mousejerry/tags/node-js/" style="font-size: 10px;">node.js</a> <a href="/mousejerry/tags/php/" style="font-size: 16.67px;">php</a> <a href="/mousejerry/tags/python/" style="font-size: 10px;">python</a> <a href="/mousejerry/tags/vscode-%E6%8F%92%E4%BB%B6/" style="font-size: 10px;">vscode,插件</a> <a href="/mousejerry/tags/vue/" style="font-size: 20px;">vue</a> <a href="/mousejerry/tags/vuex/" style="font-size: 10px;">vuex</a> <a href="/mousejerry/tags/webpack/" style="font-size: 10px;">webpack</a> <a href="/mousejerry/tags/%E5%89%8D%E7%AB%AF/" style="font-size: 10px;">前端</a> <a href="/mousejerry/tags/%E5%90%8E%E7%AB%AF/" style="font-size: 10px;">后端</a> <a href="/mousejerry/tags/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F/" style="font-size: 10px;">微信小程序</a> <a href="/mousejerry/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/" style="font-size: 10px;">数据结构</a> <a href="/mousejerry/tags/%E6%B5%8B%E8%AF%95/" style="font-size: 10px;">测试</a> <a href="/mousejerry/tags/%E7%88%AC%E8%99%AB/" style="font-size: 10px;">爬虫</a> <a href="/mousejerry/tags/%E9%9A%8F%E7%AC%94/" style="font-size: 10px;">随笔</a>
        </div>
    </div>

    
        
    <div class="widget-wrap">
        <h3 class="widget-title">分类</h3>
        <div class="widget">
            <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/mousejerry/categories/%E6%8A%80%E5%B7%A7%E5%AD%A6%E4%B9%A0/">技巧学习</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/mousejerry/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">数据结构</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/mousejerry/categories/%E8%87%AA%E5%B7%B1%E5%AD%A6%E4%B9%A0/">自己学习</a><span class="category-list-count">7</span></li><li class="category-list-item"><a class="category-list-link" href="/mousejerry/categories/%E8%AF%BE%E5%A0%82%E5%AD%A6%E4%B9%A0/">课堂学习</a><span class="category-list-count">5</span></li></ul>
        </div>
    </div>

    
        
    <div class="widget-wrap">
        <h3 class="widget-title">最新文章</h3>
        <div class="widget">
            <ul id="recent-post" class="">
                
                    <li>
                        
                        <div class="item-thumbnail">
                            <a href="/mousejerry/2020/08/10/test/" class="thumbnail">
    
    
        <span style="background-image:url(https://ejs.bootcss.com/assets/images/jake_display.png)" alt="test" class="thumbnail-image"></span>
    
</a>

                        </div>
                        
                        <div class="item-inner">
                            <p class="item-category"></p>
                            <p class="item-title"><a href="/mousejerry/2020/08/10/test/" class="title">test</a></p>
                            <p class="item-date"><time datetime="2020-08-10T01:15:21.000Z" itemprop="datePublished">2020-08-10</time></p>
                        </div>
                    </li>
                
                    <li>
                        
                        <div class="item-thumbnail">
                            <a href="/mousejerry/2020/08/05/Vue-Router%E5%B0%8F%E6%8B%93%E5%B1%95/" class="thumbnail">
    
    
        <span style="background-image:url(https://ejs.bootcss.com/assets/images/jake_display.png)" alt="Vue Router知识小补充" class="thumbnail-image"></span>
    
</a>

                        </div>
                        
                        <div class="item-inner">
                            <p class="item-category"><a class="article-category-link" href="/mousejerry/categories/%E8%87%AA%E5%B7%B1%E5%AD%A6%E4%B9%A0/">自己学习</a></p>
                            <p class="item-title"><a href="/mousejerry/2020/08/05/Vue-Router%E5%B0%8F%E6%8B%93%E5%B1%95/" class="title">Vue Router知识小补充</a></p>
                            <p class="item-date"><time datetime="2020-08-05T01:17:50.000Z" itemprop="datePublished">2020-08-05</time></p>
                        </div>
                    </li>
                
                    <li>
                        
                        <div class="item-thumbnail">
                            <a href="/mousejerry/2020/07/28/php%E6%95%B0%E7%BB%84%E7%9A%84%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0/" class="thumbnail">
    
    
        <span class="thumbnail-image thumbnail-none"></span>
    
</a>

                        </div>
                        
                        <div class="item-inner">
                            <p class="item-category"><a class="article-category-link" href="/mousejerry/categories/%E8%AF%BE%E5%A0%82%E5%AD%A6%E4%B9%A0/">课堂学习</a></p>
                            <p class="item-title"><a href="/mousejerry/2020/07/28/php%E6%95%B0%E7%BB%84%E7%9A%84%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0/" class="title">php数组的常用函数</a></p>
                            <p class="item-date"><time datetime="2020-07-28T01:58:18.000Z" itemprop="datePublished">2020-07-28</time></p>
                        </div>
                    </li>
                
                    <li>
                        
                        <div class="item-thumbnail">
                            <a href="/mousejerry/2020/07/24/php%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/" class="thumbnail">
    
    
        <span class="thumbnail-image thumbnail-none"></span>
    
</a>

                        </div>
                        
                        <div class="item-inner">
                            <p class="item-category"><a class="article-category-link" href="/mousejerry/categories/%E6%8A%80%E5%B7%A7%E5%AD%A6%E4%B9%A0/">技巧学习</a></p>
                            <p class="item-title"><a href="/mousejerry/2020/07/24/php%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/" class="title">php开发环境搭建</a></p>
                            <p class="item-date"><time datetime="2020-07-24T07:28:40.000Z" itemprop="datePublished">2020-07-24</time></p>
                        </div>
                    </li>
                
                    <li>
                        
                        <div class="item-thumbnail">
                            <a href="/mousejerry/2020/07/23/vscode%E9%85%8D%E7%BD%AEphpcs/" class="thumbnail">
    
    
        <span class="thumbnail-image thumbnail-none"></span>
    
</a>

                        </div>
                        
                        <div class="item-inner">
                            <p class="item-category"><a class="article-category-link" href="/mousejerry/categories/%E6%8A%80%E5%B7%A7%E5%AD%A6%E4%B9%A0/">技巧学习</a></p>
                            <p class="item-title"><a href="/mousejerry/2020/07/23/vscode%E9%85%8D%E7%BD%AEphpcs/" class="title">vscode配置phpcs</a></p>
                            <p class="item-date"><time datetime="2020-07-23T09:06:35.000Z" itemprop="datePublished">2020-07-23</time></p>
                        </div>
                    </li>
                
            </ul>
        </div>
    </div>


    
        
    <div class="widget-wrap">
        <h3 class="widget-title">归档</h3>
        <div class="widget">
            <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/mousejerry/archives/2020/08/">八月 2020</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/mousejerry/archives/2020/07/">七月 2020</a><span class="archive-list-count">8</span></li><li class="archive-list-item"><a class="archive-list-link" href="/mousejerry/archives/2020/06/">六月 2020</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/mousejerry/archives/2020/05/">五月 2020</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/mousejerry/archives/2020/04/">四月 2020</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/mousejerry/archives/2020/03/">三月 2020</a><span class="archive-list-count">1</span></li></ul>
        </div>
    </div>

    
        
    <div class="widget-wrap">
        <h3 class="widget-title">标签</h3>
        <div class="widget">
            <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/PHP/" rel="tag">PHP</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/apache/" rel="tag">apache</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/express/" rel="tag">express</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/js/" rel="tag">js</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/node-js/" rel="tag">node.js</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/php/" rel="tag">php</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/python/" rel="tag">python</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/vscode-%E6%8F%92%E4%BB%B6/" rel="tag">vscode,插件</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/vue/" rel="tag">vue</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/vuex/" rel="tag">vuex</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/webpack/" rel="tag">webpack</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/%E5%89%8D%E7%AB%AF/" rel="tag">前端</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/%E5%90%8E%E7%AB%AF/" rel="tag">后端</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F/" rel="tag">微信小程序</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/" rel="tag">数据结构</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/%E6%B5%8B%E8%AF%95/" rel="tag">测试</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/%E7%88%AC%E8%99%AB/" rel="tag">爬虫</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/mousejerry/tags/%E9%9A%8F%E7%AC%94/" rel="tag">随笔</a><span class="tag-list-count">1</span></li></ul>
        </div>
    </div>

    
        
    <div class="widget-wrap widget-list">
        <h3 class="widget-title">链接</h3>
        <div class="widget">
            <ul>
                
                    <li>
                        <a target="_blank" rel="noopener" href="http://hexo.io">Hexo</a>
                    </li>
                
            </ul>
        </div>
    </div>


    
    <div id="toTop" class="fa fa-angle-up"></div>
</aside>
            
        </div>
        <footer id="footer">
    <div class="outer">
        <div id="footer-info" class="inner">
            &copy; 2020 smalljerry<br>
            Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>. Theme by <a target="_blank" rel="noopener" href="http://github.com/ppoffice">Hexo</a>
            .<br/><a target="_blank" rel="noopener" href="http://github.com/ghaseminya"></a>

            <a href="">lala</a>
        </div>
    </div>
</footer>

        
    
    <script>
    var disqus_config = function () {
        
            this.page.url = 'http://dsjerry.gitee.io/mousejerry/2020/07/24/php%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/';
        
        this.page.identifier = 'php开发环境搭建';
    };
    (function() { 
        var d = document, s = d.createElement('script');  
        s.src = '//' + 'dsjerry' + '.disqus.com/embed.js';
        s.setAttribute('data-timestamp', +new Date());
        (d.head || d.body).appendChild(s);
    })();
</script>



    
        
<script src="/mousejerry/libs/lightgallery/js/lightgallery.min.js"></script>

        
<script src="/mousejerry/libs/lightgallery/js/lg-thumbnail.min.js"></script>

        
<script src="/mousejerry/libs/lightgallery/js/lg-pager.min.js"></script>

        
<script src="/mousejerry/libs/lightgallery/js/lg-autoplay.min.js"></script>

        
<script src="/mousejerry/libs/lightgallery/js/lg-fullscreen.min.js"></script>

        
<script src="/mousejerry/libs/lightgallery/js/lg-zoom.min.js"></script>

        
<script src="/mousejerry/libs/lightgallery/js/lg-hash.min.js"></script>

        
<script src="/mousejerry/libs/lightgallery/js/lg-share.min.js"></script>

        
<script src="/mousejerry/libs/lightgallery/js/lg-video.min.js"></script>

    
    
        
<script src="/mousejerry/libs/justified-gallery/jquery.justifiedGallery.min.js"></script>

    



<!-- Custom Scripts -->

<script src="/mousejerry/js/main.js"></script>


    </div>
</body>
</html>